<div id="zerocms_media_gallery" data-url_actions="<%= actions_zerocms_admin_media_path(actions: @show_file_actions, dimension: params[:dimension]) %>" data-extra-params="<%= {versions: params[:versions], thumb_size: params[:thumb_size], formats: @media_formats.join(","), media_formats: @media_formats.join(","), dimension: params[:dimension], private: params[:private]}.to_json %>" data-versions="<%= params[:versions] %>" data-thumb_size="<%= params[:thumb_size] %>" data-formats="<%= @media_formats.join(",") %>" data-folder="<%= @folder %>" data-url="<%= ajax_zerocms_admin_media_path(actions: @show_file_actions) %>" data-dimension="<%= params[:dimension] %>">
  <div class="panel panel-default">
    <div class="panel-heading">
      <div class="row">
        <div class="col-md-12">
          <div class="row">
              <div class="col-md-8">
                  <ol style="margin-bottom: 0; padding-bottom: 0" class="breadcrumb media_folder_breadcrumb"></ol>
              </div>
              <div class="col-md-4">
                  <%= form_tag '#', id: 'zerocms_search_form', class: 'input-group' do %>
                      <input placeholder="<%= zerocms_t('zerocms.admin.media.folder_file_name') %>.." class="form-control required" name="folder">
                          <div class="input-group-btn">
                              <button type="submit" class="btn btn-default"><i class="fa fa-search"></i> <%= t('zerocms.common.search', default: 'Search') %></button>
                              <div class="btn-group" role="group">
                                  <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><i class="fa fa-cogs"></i> <span class="caret"></span></button>
                                  <ul class="dropdown-menu pull-right">
                                      <li><a href="#" class="zerocms_media_reload" data-action="reload"><i class="fa fa-refresh"></i> <%= zerocms_t('zerocms.admin.media.reload') %></a></li>
                                      <% if @show_file_actions %>
                                          <li><a href="#" class="add_folder"> <i class="fa fa-plus"></i> <%= zerocms_t("zerocms.admin.button.add_folder") %></a></li>
                                      <% end %>
                                      <li><a href="#" class="zerocms_media_reload" data-action="clear_cache"><i class="fa fa-recycle"></i> <%= zerocms_t('zerocms.admin.media.clear_cache') %></a></li>
                                  </ul>
                              </div>
                          </div>
                  <% end %>
              </div>
          </div>
        </div>
      </div>
    </div>
    <div class="panel-body">
      <div class="row" style="margin-bottom: 16px">
        <div class="col-md-9 media_browser_list" data-next-page="<%= @next_page %>">
          <%= render "files_list", files: @files, folders: @tree[:folders] %>
        </div>

        <div class="col-md-3 media_file_info_col">
          <ul class="nav nav-tabs nav-justified" role="tablist">
            <li role="presentation" class="active"><a href="#zerocms_media_upload" class="link_media_upload" role="tab" data-toggle="tab"><%= t("zerocms.admin.button.upload_file") %></a></li>
            <li role="presentation"><a href="#zerocms_media_info" class="link_media_info" role="tab" data-toggle="tab"><%= t("zerocms.admin.media.info") %></a></li>
          </ul>
          <div class="tab-content">
            <div role="tabpanel" class="tab-pane active" id="zerocms_media_upload">
                <div class="zerocms_media_fileuploader" data-input-id="zerocms-upload-files" data-url="<%= upload_zerocms_admin_media_path(actions: @show_file_actions, dimension: params[:dimension]) %>" data-dragDropStr="<%= t("zerocms.admin.button.drag_drop") %>" data-uploadStr="<%= t("zerocms.admin.button.upload_file") %>"><%= t("zerocms.admin.button.upload_file") %></div>
                <hr/>
                <form id="zerocms_media_external">
                    <fieldset>
                        <legend><%= t("zerocms.admin.media.external", default: 'From URL') %></legend>
                        <div class="form-group">
                            <input type="text" name="remote_file" class="form-control" placeholder="http://..." class="required">
                        </div>
                        <div class="form-group">
                            <button type="submit" class="btn btn-primary"><%= t("zerocms.admin.button.submit") %></button>
                        </div>
                    </fieldset>
                </form>
            </div>
            <div role="tabpanel" class="tab-pane" id="zerocms_media_info">
              <div class="media_file_info"></div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>
<script>jQuery(function () {
  zerocms_init_media($("#zerocms_media_gallery"));
});</script>
